"""
* P8218 【深进1.例1】求区间和
* 这是一道前缀和题
* 前缀和题的数据基础是数列求和相关的内容
* 题解可以看：https://www.luogu.com.cn/problem/solution/P8218
"""


def resolution1():
    n = int(input())
    # 构造原始数组
    origin_array = [0]
    origin_array.extend(list(map(int, input().split())))
    # 构造前缀和数组
    prefix_sum_array = [0]
    for i in range(1, len(origin_array)):
        prefix_sum_array.append(prefix_sum_array[i-1] + origin_array[i])
    # 逐组处理差分情况
    m = int(input())
    for i in range(m):
        li, ri = map(int, input().split())
        print(prefix_sum_array[ri] - prefix_sum_array[li-1])


if __name__ == '__main__':
    resolution1()